package com.damionew.website.service.back;

import java.util.List;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.damionew.website.dao.back.UserDao;
import com.damionew.website.model.back.User;

@Service
public class UserService {
    @Autowired
    private UserDao userDao;
    public List<User> getUserList(String sortName,String sortOrder) {
	List<User> list =  userDao.getUserList(sortName,sortOrder);
	return list;
    }
    public void addUser(User user) {
	//MD5算法两次，加盐(account)
	String password =new SimpleHash("MD5",user.getPassword(),user.getAccount(),2).toHex();
	user.setPassword(password);
	userDao.addUser(user);
    }
    public void updateUser(User user) {
	
	userDao.updateUser(user);
    }
    public void deleteUser(String id) {
	userDao.deleteUser(id);
    }
    //获取用户总数
    public int getUserTotal() {
	List<User> list = userDao.getUserTotal();
	int total = list.size();
	return total;
    }
}
